package com.zifan.yygh.controller;

import com.zifan.common.result.Result;
import com.zifan.yygh.model.hosp.Hospital;
import com.zifan.yygh.service.HospitalService;
import com.zifan.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Zifan
 * @date 2021年09月29日13:58
 */
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("/list/{page}/{limit}")
    public Result index(@PathVariable("page") Integer page,
                        @PathVariable("limit") Integer limit,
                        HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> resPage = hospitalService.selectPage(page, limit, hospitalQueryVo);
        return Result.ok(resPage);
    }

    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result lock(
            @PathVariable("id") String id,
            @PathVariable("status") Integer status
    ) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "获取医院详情")
    @GetMapping("show/{id}")
    public Result show(
            @PathVariable String id) {
        return Result.ok(hospitalService.show(id));
    }

}
